package com.tien.utils.tree;


/**
 * @author  tienxin 
 * @E-mail  g.tianxin@gmail.com
 * @version 2012-2-19 下午07:53:38
 */
public class Node {
	/**
	 * 节点编号
	 */
	public String id;

	/**
	 * 节点内容
	 */
	public String text;

	/**
	 * 父节点编号
	 */
	public String parentId;

	/**
	 * 孩子节点列表
	 */
	public Children children = new Children();

	// 深度遍历，拼接JSON字符串
	public String toString() {
		String result = "{" + "menu_id : '" + id + "'" + ", menu_name : '" + text + "'";

		if (children != null && children.getSize() != 0) {
			result += ", children : " + children.toString();
		} else {
			result += ", leaf : true";
		}

		return result + "}";
	}

	// 对子节点进行横向排序
	public void sortChildren() {
		if (children != null && children.getSize() != 0) {
			children.sortChildren();
		}
	}
}
 